package com.powernode.listeners;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

/**
 * ServletContext监听器
 * 内容: SSM
 * 作者: 丁鹏
 */
//@WebListener注解开启监听器
//@WebListener
public class AppListener implements ServletContextListener {

    //application地域

    @Override
    public void contextInitialized(ServletContextEvent sce) {
        System.out.println("当前工程正在启动中...");
        ServletContext application = sce.getServletContext();
        String path = application.getContextPath();
        application.setAttribute("ctx", path);
    }

    @Override
    public void contextDestroyed(ServletContextEvent sce) {
        System.out.println("当前工程被重新启动了...");
    }
}
